<template>
  <div  >
      <div  id="app">
            <div  >
                <div   class="backBtn" @click="$router.back(-1)">
                    <i  class="icon iconfont icon-back"></i>
                </div>
                <div  class="wrapper bg_2">
                    <div  class="nickBox">
                        <div  class="nickInfo">
                            <span  class="imgBox" style="background-color: rgb(255, 255, 255);"><img  src="/static/img/logo_btn.png" alt=""></span><span >乐慧城市</span>
                        </div>
                        <span  class="nickTitle">邀您注册乐慧城市智慧经理</span>
                    </div>
                    <div  class="btnCont" @click="regFn">
                        立即注册&nbsp;&nbsp;赚大钱
                    </div>
                </div>
            </div>
        </div>
	</div>
</template>

<script>
import { MemberBaseInfoUrl,RechargePayUrl,CashoutAddUrl } from "@/api/axiosFun";
import { UnifiedOrder,OrderQuery,ConfigJs } from "@/api/login";

export default {
  name: "Index",
  data() {
    return {
      msg: "Welcome to Your Vue.js App",
      bannerList: [],
      datalist: [],
      currentIndex: 1,
      page: 1,
      pageSize: 100,
      traderType: 1,
      nowMoney: "",
      cityId: "",
      orderNum: false,
      Latitude: "",
      Longitude: "",
      datainfo:{},
      payinfo:{},
      oid: ""
    };
  },
  created() {
    if(this.$route.params && this.$route.params.id){
      this.datainfo = this.$route.params.id;
    }else {
      this.datainfo = {};
    }
    this.getConfig();
  },
  mounted() {
    //this.init();
  },
  methods: {
    init() {
      MemberBaseInfoUrl().then(res => {
        console.log(res);
        if (res.errCode == 0) {
          //this.bannerList = res.data;
        }
      });
    },
    jumpIndex(){
      this.$router.replace('/')
    },
    regFn(){
       //this.$router.replace({ name: "qrcodeVipTuijian"});
       this.$router.replace({ name: "register"});
    },
    payType(index){
      this.currentIndex = index;
    },
    // getPayinfo(){
    //   UnifiedOrder({
    //     traderId:this.datainfo.id,
    //     payType:this.currentIndex,
    //     money:parseFloat(this.nowMoney)
    //   }).then(res=>{
    //     console.log(res);
    //     if(res.data.data!=null){
    //       this.payinfo=res.data.data
    //       this.pay()
    //     }
    //   })
    // },
    goRechargeFn(){
      console.log(999);
      CashoutAddUrl().then(res => {
        console.log(res);
        //if (res.errCode == 0) {
          //this.bannerList = res.data;
        //}
      });
        // RechargePayUrl({
        //   money:Number(this.nowMoney)
        // }).then(res=>{
        //   console.log(res);
        //   if(res.errCode == 0){
        //     this.payinfo=res.data;
        //     this.pay()
        //   }
        // });
    },
    pay(){
        console.log(this.payinfo);
     let that=this
      wx.chooseWXPay({
        appId:'wx9b4743a1848616d3',      
        timestamp: this.payinfo.timeStamp, // 支付签名时间戳，注意微信jssdk中的所有使用timestamp字段均为小写。但最新版的支付后台生成签名使用的timeStamp字段名需大写其中的S字符
        nonceStr: this.payinfo.nonceStr, // 支付签名随机串，不长于 32 位
        package: this.payinfo.package, // 统一支付接口返回的prepay_id参数值，提交格式如：prepay_id=\*\*\*）
        signType: 'MD5', // 签名方式，默认为'SHA1'，使用新版支付需传入'MD5'
        paySign: this.payinfo.paySign, // 支付签名
        success: function (res) {
            // 支付成功后的回调函数
            console.log(res);
            that.orderQuery();
        },
        cancel: function(res) {
            console.log(res);
        },
        fail:function(res){
            console.log(res);
            //支付失败
        }
      });
    },
    getConfig(){
      ConfigJs(window.location.href).then((res)=>{
          console.log(res);
        let data=res.data.data
        wx.config({
            debug: false, // 开启调试模式,调用的所有api的返回值会在客户端alert出来，若要查看传入的参数，可以在pc端打开，参数信息会通过log打出，仅在pc端时才会打印。
            appId: data.appId, // 必填，公众号的唯一标识
            timestamp: data.timestamp, // 必填，生成签名的时间戳
            nonceStr: data.nonceStr, // 必填，生成签名的随机串
            signature: data.signature,// 必填，签名
            jsApiList: ['chooseWXPay'] // 必填，需要使用的JS接口列表
        });
      })
    },
    orderQuery(){
      OrderQuery(this.payinfo.outNo).then(res=>{
          console.log(res);
           if (res.data.data!='支付成功'){
                setTimeout(function(){
                    this.orderQuery()
                },2000);
            }else{
                //Toast(res.data.data);
                this.$router.push('/my')
           }
      })
    },
  }
};
</script>

<!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped>
.backBtn {
    width: 1.25rem;
    height: 1.25rem;
    background: -webkit-gradient(linear,left top,right top,from(rgba(0,170,255,.5)),to(rgba(0,133,255,.5)));
    background: linear-gradient(90deg,rgba(0,170,255,.5),rgba(0,133,255,.5));
    display: -webkit-box;
    display: -ms-flexbox;
    display: flex;
    -webkit-box-orient: vertical;
    -webkit-box-direction: normal;
    -ms-flex-direction: column;
    flex-direction: column;
    -webkit-box-pack: center;
    -ms-flex-pack: center;
    justify-content: center;
    -webkit-box-align: center;
    -ms-flex-align: center;
    align-items: center;
    -ms-flex-line-pack: center;
    align-content: center;
    position: fixed;
    top: .44rem;
    left: .44rem;
    z-index: 9999;
    border-radius: 50%;
    overflow: hidden;
}
.iconfont {
    font-family: "iconfont" !important;
    font-size: 16px;
    font-style: normal;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}
.backBtn i {
    font-size: .64rem;
    font-weight: 700;
    color: #fff;
}
.wrapper {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-clip: content-box;
    background-size: 100% 100%;
    background-repeat: no-repeat;
    background-origin: content-box;
    font-size: .36rem;
    color: #fff;
}
.wrapper.bg_2 {
    background-image: url(/static/img/tuijian_bg4.jpg);
}
.nickBox {
    display: -webkit-box;
    display: -ms-flexbox;
    display: flex;
    -webkit-box-orient: vertical;
    -webkit-box-direction: normal;
    -ms-flex-direction: column;
    flex-direction: column;
    -webkit-box-pack: center;
    -ms-flex-pack: center;
    justify-content: center;
    -webkit-box-align: center;
    -ms-flex-align: center;
    align-items: center;
    -ms-flex-line-pack: center;
    align-content: center;
    text-align: center;
    padding: .1rem .3rem;
    font-size: .28rem;
    margin: .6rem 0;
}
.nickBox .nickInfo {
    color: #fff;
    padding-bottom: .2rem;
}
.nickBox .nickInfo span {
    font-size: .36rem;
}
.nickBox .nickInfo .imgBox {
    display: block;
    width: 1.2rem;
    height: 1.2rem;
    border-radius: 50%;
    border: 2px solid #fff;
    overflow: hidden;
    margin-bottom: .2rem;
}   
.nickBox .nickInfo .imgBox img {
    width: 100%;
}
.nickBox .nickInfo span {
    font-size: .36rem;
}
.nickBox .nickTitle {
    display: block;
    font-size: .42rem;
    line-height: .4rem;
    color: #fff;
    font-weight: 700;
    padding: .1rem 0 .05rem;
    letter-spacing: 2px;
}
.btnCont {
    position: fixed;
    right: 1.5rem;
    bottom: .71rem;
    left: 1.5rem;
    height: 1.42rem;
    line-height: 1.42rem;
    color: #fff;
    text-align: center;
    font-size: .56rem;
    background: -webkit-gradient(linear,left top,right top,from(#f42836),to(#cc0e80));
    background: linear-gradient(90deg,#f42836,#cc0e80);
    border-radius: .71rem;
    -webkit-overflow-scrolling: touch;
    z-index: 9999;
    -webkit-transform: translateZ(1px);
    transform: translateZ(1px);
}
.wrapper.bg_2 .btnCont {
    left: 1rem;
    right: 1rem;
    bottom: .71rem;
    border-radius: .71rem;
    background: linear-gradient(120deg,#782de4,#410099);
}
</style>
